FROM docker.io/python:3.6.15-bullseye

COPY code/requirements.txt /tmp/requirements.txt
RUN sed -i -E 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \
    && sed -i -E 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \
    && echo 'deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main' >> /etc/apt/sources.list \
    && curl -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt update && apt-get install -y libgdal-dev postgresql-client-14 \
    && pip install -r /tmp/requirements.txt -i https://mirrors.aliyun.com/pypi/simple

COPY code/src /app
RUN set -x & useradd algo

WORKDIR /app
CMD ["python3", "app.py"]
